package Reflect;

import java.lang.reflect.Field;

public class ReflectDemo8 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        Teacher t = new Teacher();
        t.name = "zhangsan";
        System.out.println(t);

        Class cls = Class.forName("Reflect.Teacher");
        Object obj = cls.newInstance();

        Field f = cls.getField("name");
        f.set(obj,"lisi");
        System.out.println(obj);

        System.out.println(f.get(obj));
    }
}
